#include "checkbox.hpp"
#include "content/data_provider.hpp"
#include "imgui.h"

void checkbox::update_data (bindable_base *data)
{
    if (value_)
        value_->attach (data);
}

void checkbox::init_content (const xml_node &node)
{
    ui_control::init_content (node);
    value_ = create_data (node.attribute ("value").as_string (), data_category::boolean);
}

void checkbox::draw_self ()
{
    bool v = value_->get_boolean ();
    if (ImGui::Checkbox ("##Value", &v))
    {
        value_->set_boolean (v);
    }
}
